package com.hilton.tigershark.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.webkit.WebView;

public class CustomizedWebview extends WebView {
    private OnChangedListener mListener;

    public interface OnChangedListener {
        public void onScrollChanged(int l, int t, int oldl, int oldt);
        public void onTouch(WebView v, MotionEvent event);
    }

    public CustomizedWebview(Context context) {
        super(context);
    }

    public CustomizedWebview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomizedWebview(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setOnChangeListener(OnChangedListener l) {
        mListener = l;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (mListener != null) {
            mListener.onScrollChanged(l, t, oldl, oldt);
        }
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        final boolean r = super.onTouchEvent(event);
        if (mListener != null) {
            mListener.onTouch(this, event);
        }
        return r;
    }
}